#include <iostream>
#define N 100

using namespace std;

void readintVector(int array[], int elements){
for (int i=0; i<elements; i++){
	cout<<"a["<<i<<"]=";
	cin>>array[i];
	cout<<"\n";}
}

void printintVector(int array[], int elements){
for (int i=0; i<elements; i++){
	cout<<array[i]<<" ";}
	cout<<"\n";
}

int perm_right(int array[], int elements){
int i, j, aux, temp;
for(i=0; i<elements; i++){
	j=i+1;
	aux=array[i];
	while (j!=i){
		if(j==elements){
			j=0;
			temp=array[j];
			array[j]=aux;
			aux=temp;
			if(i!=0)
				++j;
			}			
			else {
				temp=array[j];
				array[j]=aux;
				aux=temp;
				++j;}	
		}
		if(j!=0)
			array[j]=aux;
		printintVector(array, elements);	
	}
}

int main(){
int array[N];
int elements;
cout<<"Type the number of elements you want in the array: ";
cin>>elements;

readintVector(array, elements);

cout<<"The original array is ";
for(int i=0; i<elements; i++){
	cout<<array[i]<<" ";}
cout<<endl;
cout<<"The permutations with one position to the right are: "<< endl;
perm_right(array, elements);

return 0;
}
